<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
  <title>login</title>
  <link rel="stylesheet" href="/static/js/layui/css/layui.css">
  <style>
    body{
      background-image: url("/static/images/bg.jpg");
      background-size: 100%;
      background-repeat: no-repeat;
      background-color: #000;
    }
  </style>
</head>
<body>
<style>
.demo-reg-container{width: 360px; margin: 21px auto 0;}
.demo-reg-other .layui-icon{position: relative; display: inline-block; margin: 0 2px; top: 2px; font-size: 26px;}
.layui-input{
  height: 46px;background-color: rgba(255, 255, 255, 0.5);
}
.layui-btn{height: 46px;background-color: rgba(0, 0, 255, 0.7);letter-spacing:15px;}
</style>
<form class="layui-form">
  <div class="demo-reg-container" style="margin-top: 13%;">
    <div class="layui-form-item">
      <div class="layui-row">
          <div class="layui-input-wrap">
            <div class="layui-input-prefix">
              <i class="layui-icon layui-icon-cellphone"></i>
            </div>
            <input type="text" value="wenwu" name="a" lay-verify="required" placeholder="账号" lay-reqtext="请填写手机号" autocomplete="off" class="layui-input" id="reg-cellphone">
          </div>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-wrap">
        <div class="layui-input-prefix">
          <i class="layui-icon layui-icon-password"></i>
        </div>
        <input type="password" name="b" value="wuleidelo" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input" id="reg-password" lay-affix="eye">
      </div>
    </div>
   
    <div class="layui-form-item">
      <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-reg">登录</button>
    </div>
    <div class="layui-form-item demo-reg-other">
      <a href="#login">注册</a>
      <a href="/w" style="float: right;">官网</a>
    </div>
  </div>
</form>
  
    <script src="/static/js/layui/layui.js"></script>
<script>
layui.use(function(){
  var $ = layui.$;
  var form = layui.form;
  var layer = layui.layer;
  var util = layui.util;
  
  // 提交事件
  form.on('submit(demo-reg)', function(data){
    var field = data.field; // 获取表单字段值
    $.ajax({
        url:'/tasks/user/login',
        dataType:'json',
        type:'post',
        data:field,
        success:function(resp){
          if( resp.code == 200 ){
            document.cookie = "data="+JSON.stringify(resp.data)+";path=/";
            location.href = "/";
          }
        }
    });
    
    return false; // 阻止默认 form 跳转
  });


});

</script>

</body>
</html>